using Aliphant.Mvvm.XEvent.Ioc;
using GrpcClient.UI;
using GrpcClient.Views;
using System.Windows;


namespace GrpcClient
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public static LoadingWindow loading = new LoadingWindow();
        public static TopThumb? topThumb;

        private void RegistryType()
        {
            XContainerLocator.Instance.RegisterNavigation<TestViewModule>("testa");
            XContainerLocator.Instance.RegisterNavigation<TestViewBModule>("testb");

            XContainerLocator.Instance.RegisterNavigation<NavigationBar>("navigationBar");
            XContainerLocator.Instance.RegisterNavigation<UserCenterControl>("userCenter");
            XContainerLocator.Instance.RegisterNavigation<SettingControl>("setting");
            XContainerLocator.Instance.RegisterNavigation<WebViewControl>("webview");
            XContainerLocator.Instance.RegisterNavigation<WebAppControl>("webApp");
            XContainerLocator.Instance.RegisterNavigation<BrowserTabControl>("browser");
        }

        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            RegistryType();
            await ResourceManager.Instance.Loading();

            Current.MainWindow = loading;
            ResourceManager.Instance.UpdateLoadingMessageEvent += loading.UpdateMessage;
            Current.MainWindow.Show();

        }

        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);
            ResourceManager.Instance.Exit();
            if (loading != null)
                loading.Close();
        }

    }

}
